using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Portal.BO.Editoral.CommentManagement;
using Portal.User.Security;

namespace Portal.GUI.EditoralOffice.MainOffce.Menu
{
    public partial class MnuStatistic : System.Web.UI.UserControl
    {
        #region private method
        private void CreateMenuNews()
        {
            if (!IsPostBack)
            {
                DataTable table = new DataTable();//= CommonHelper.GetDataPermission(RolePrefix.BIENTAPVIEN, 1);
                //MainSecurity objSecu = new MainSecurity();            
                //Role role = objSecu.GetRole(HttpContext.Current.User.Identity.Name);            
                table = CommonHelper.GetDataPermission("", 3);

                DataView dv = table.DefaultView;
                dv.Sort = "Permission_ID";
                //dlMenuNews.DataSource = dv;
                //dlMenuNews.DataBind();
                dtlMenuNews.DataSource = dv;
                dtlMenuNews.DataBind();

                if (table.Rows.Count == 0)
                {
                    table1.Visible = false;
                    tableBottom.Visible = false;
                }
            }
        }        
        #endregion
        #region Page Load
        private void SetClassForLink(HtmlGenericControl hl)
        {
            hl.Attributes.Remove("class");
            hl.Attributes.Add("class", "Menuleft_Item_Select");
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            itemStatistics.NavigateUrl = "~/office/statistics.chn";
            /*            
            itemStatContent.NavigateUrl = "~/office/statcontent.chn";
            itemStatCategory.NavigateUrl = "~/office/statcategory.chn";
            itemStatPostContentByUser.NavigateUrl = "~/office/statpostcontent.chn";
            itemLogList.NavigateUrl = "~/office/log_users.chn";
             */
            String cpmode = Request.QueryString["cpmode"];
            if (cpmode == "statistics")
                SetClassForLink(divThongKe); 

            CreateMenuNews();
        }
        #endregion
        #region dlMenuNews_ItemDataBound
        protected void dlMenuNews_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
            //    Literal ltrCount = (Literal)e.Item.FindControl("ltrCount");
            //    HiddenField IsCount = (HiddenField)e.Item.FindControl("IsCount");
                HiddenField Cpmode = (HiddenField)e.Item.FindControl("Cpmode");
                HtmlGenericControl divItem = (HtmlGenericControl)e.Item.FindControl("divItem");
                String strCpmode = Request.QueryString["cpmode"];
                //if (Cpmode.Value == strCpmode)
                //{
                //    divItem.Attributes.Remove("class");
                //    divItem.Attributes.Add("class", "Menuleft_Item_Select");
                //}

                if (Session["cpmode"] != null)
                {
                    String cpmodeSession = Session["cpmode"].ToString();
                    if (cpmodeSession == Cpmode.Value)
                    {
                        divItem.Attributes.Remove("class");
                        divItem.Attributes.Add("class", "Menuleft_Item_Select");
                    }
                }
            }
            //CreateMenuNews();
        }
        #endregion

        protected void dlMenuAlbum_ItemCommand(object source, DataListCommandEventArgs e)
        {
            Session["cpmode"] = e.CommandName;
            Response.Redirect(e.CommandArgument.ToString());
        }
    }
}